1936A - Bitwise Operation Wizard - CodeForces Solution


bitmasks constructive algorithms greedy interactive math

Please click on ads to support us..

C++ Code:

#include <iostream>
#include <cstdio>
using namespace std;

int t,n;

void solve()
{
	scanf("%d",&n);
	int realn = 0;
	for (int i = 1;i < n;i ++)
	{
		printf("? %d %d %d %d\n",realn,realn,i,i);
		fflush(stdout);
		char ch = getchar();
		while (ch != '<' && ch != '>' && ch != '=') ch = getchar();
		if (ch == '<') realn = i;
	}
	int res = realn;
	for (int i = 0;i < n;i ++)
	{
		if (i == realn) continue;
		printf("? %d %d %d %d\n",realn,res,realn,i);
		fflush(stdout);
		char ch = getchar();
		while (ch != '<' && ch != '>' && ch != '=') ch = getchar();
		if (ch == '<') res = i;
		else if (ch == '=')
		{
			printf("? %d %d %d %d\n",res,res,i,i);
			fflush(stdout);
			char ch = getchar();
			while (ch != '<' && ch != '>' && ch != '=') ch = getchar();
			if (ch == '>') res = i;
		}
	}
	printf("! %d %d\n",realn,res);
	fflush(stdout);
}

int main()
{
	scanf("%d",&t);
	while (t --) solve();
}


Comments

Submit
0 Comments
More Questions

1405A - Permutation Forgery
1733A - Consecutive Sum
1733B - Rule of League
1733C - Parity Shuffle Sorting
1264A - Beautiful Regional Contest
1695A - Subrectangle Guess
467B - Fedor and New Game
252C - Points on Line
735C - Tennis Championship
992A - Nastya and an Array
554A - Kyoya and Photobooks
79B - Colorful Field
265B - Roadside Trees (Simplified Edition)
1362C - Johnny and Another Rating Drop
1214C - Bad Sequence
1091B - New Year and the Treasure Geolocation
244A - Dividing Orange
1061C - Multiplicity
1312A - Two Regular Polygons
801A - Vicious Keyboard
510B - Fox And Two Dots
616D - Longest k-Good Segment
1604A - Era
555B - Case of Fugitive
551A - GukiZ and Contest
1399F - Yet Another Segments Subset
1371C - A Cookie for You
430B - Balls Game
1263A - Sweet Problem
1332B - Composite Coloring